package condition;

import elements.Element;
import exceptions.IllegalConditionException;

/**
 * A class of unary composed conditions, representing the negation of
 * a given operand.
 * 
 * @version	3.0
 * @author 	Lies Tambeur 	r0264469	2Bcwsbbh
 * @author	Eline Vanrykel	r0264543	2Bcwselt
 *
 */
public class Not extends UnaryComposedCondition {

	/**
	 * Initialize this new Not with a given operand.
	 *
	 * @param  condition
	 *         The condition for this new Not.
	 * @effect This new Not is initialized as a unary expression
	 *         with the given condition as its condition.
	 */
	public Not(Condition condition) throws IllegalConditionException {
		super(condition);
	}

	/**
	 * Returns true only if the condition is false, and the other way around.
	 */
	@Override
	public boolean evaluate(Element element) {
		return !this.condition.evaluate(element);
	}
	
	@Override
	public String toString(){
		return "( not" +this.getCondition().toString() + " )";
	}
	
	@Override
	public boolean equals(Object object){
		if(object == null || this==null){
			return false;
		}
		return this.toString().equals(object.toString());
	}

}
